# Contributor: Kevin Daudt <kdaudt@alpinelinux.org>
# Maintainer: leso-kn <info@lesosoftware.com>
pkgname=go-swag
pkgver=1.8.12
pkgrel=2
pkgdesc="Automatically generate RESTful API documentation with Swagger 2.0 for Go"
url="https://github.com/swaggo/swag"
arch="all"
license="MIT"
makedepends="go"
# upstream issue (enums-test-32bit): https://github.com/swaggo/swag/issues/1633
source="
	$pkgname-$pkgver.tar.gz::https://github.com/swaggo/swag/archive/refs/tags/v$pkgver.tar.gz
	enums-test-32bit.patch
	"
builddir="$srcdir/swag-$pkgver"

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	make build
}

check() {
	# do not NOT as root! some tests fail if run as root.
	export GOROOT="/usr/lib/go"

	if [ "$CARCH" = "riscv64" ]; then
		# TestGen_BuildDescriptionWithQuotes makes use of 'go build -buildmode=plugin' which is not supported on riscv64.
		go test -run '!(^(TestGen_BuildDescriptionWithQuotes)$)' ./...
	else
		make test
	fi
}

package() {
	install -Dm0755 swag "$pkgdir"/usr/bin/go-swag
	ln -s /usr/bin/go-swag "$pkgdir/usr/bin/swag"
}

sha512sums="
29c29c0a9bd17c4b783436967c7c2a1a0fcde2ad11dfd4cb6ee26991f26c49c6fdd541c7a5d62628c3aa9b4f56a657d1ecaf46dd48b57264f4420cda2e984fee  go-swag-1.8.12.tar.gz
24a30976e7aab4708cc8e740ff77a99d5ce5b0bde0dffe4598161ab53ebbaa3ac39c19acb83d290cca9a38bc3515cb10ec8310def6a9a016f98ff86075d591a2  enums-test-32bit.patch
"
